Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Prevent Perl input record separator change in TO dbdump API#2977

Merged
dangogh merged 1 commit into
apache:masterfrom
rawlinp:fix-perl-db-dump-chomp
Nov 5, 2018
Merged

Prevent Perl input record separator change in TO dbdump API#2977
dangogh merged 1 commit into
apache:masterfrom
rawlinp:fix-perl-db-dump-chomp

Conversation

@rawlinp
Copy link
Copy Markdown
Contributor

@rawlinp rawlinp commented Oct 31, 2018

What does this PR do?

Due to the way this code was previously written, the first call to the
dbdump API is successful, but subsequent calls are broken because the
chomp() function no longer strips trailing whitespace from the output of
the hostname command. This ends up breaking the response headers
because of the unexpected newline, causing traffic_ops_golang to emit
this error and return a 502:

    http: proxy error: net/http: HTTP/1.x transport connection broken:
    malformed MIME header line: -20181031125221.pg_dump"

By only locally declaring $/ (undefined) in the do block, subsequent
calls to chomp() actually strip newlines because $/ == "\n" by
default.

Which TC components are affected by this PR?

  • Documentation
  • Grove
  • Traffic Analytics
  • Traffic Monitor
  • Traffic Ops
  • Traffic Ops ORT
  • Traffic Portal
  • Traffic Router
  • Traffic Stats
  • Traffic Vault
  • Other _________

What is the best way to verify this PR?

curl -kvs -H "$MOJO_COOKIE" "https://trafficops.example.com/api/1.2/dbdump" -OJ

Check all that apply

  • This PR includes tests
  • This PR includes documentation updates
  • This PR includes an update to CHANGELOG.md
  • This PR includes all required license headers
  • This PR includes a database migration (ensure that migration sequence is correct)
  • This PR fixes a serious security flaw. Read more: www.apache.org/security

@rawlinp rawlinp added bug something isn't working as intended Traffic Ops related to Traffic Ops labels Oct 31, 2018
@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Oct 31, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/2700/
Test PASSed.

Due to the way this code was previously written, the first call to the
dbdump API is successful, but subsequent calls are broken because the
chomp() function no longer strips trailing whitespace from the output of
the `hostname` command. This ends up breaking the response headers
because of the unexpected newline, causing traffic_ops_golang to emit
this error and return a 502:

    http: proxy error: net/http: HTTP/1.x transport connection broken:
    malformed MIME header line: -20181031125221.pg_dump"

By only locally declaring $/ (undefined), subsequent calls to `chomp()`
actually strip newlines because `$/ == "\n"` by default.
@rawlinp rawlinp force-pushed the fix-perl-db-dump-chomp branch from eb451b1 to 419fcf9 Compare November 2, 2018 16:32
@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Nov 2, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/2716/
Test PASSed.

@dangogh dangogh self-assigned this Nov 5, 2018
@dangogh dangogh merged commit 612bedd into apache:master Nov 5, 2018
@rawlinp rawlinp deleted the fix-perl-db-dump-chomp branch November 5, 2018 23:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug something isn't working as intended Traffic Ops related to Traffic Ops

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants